var a = require("../../../@babel/runtime/helpers/defineProperty"), t = getApp();

Page({
    data: {
        tabsIndex: 0,
        ordinaryIndex: 0,
        ordinaryArray: [ {
            name: "图文",
            value: 1
        }, {
            name: "视频",
            value: 4
        }, {
            name: "音频",
            value: 3
        }, {
            name: "文章",
            value: 2
        }, {
            name: "直播"
        } ],
        searchText: "",
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        listData: [],
        networkLoading: !1,
        is_release: !1
    },
    onLoad: function(a) {
        this.getListData();
    },
    onReady: function() {},
    onShow: function() {},
    setTabsIndex: function(t) {
        var e = t.currentTarget.dataset.index, i = t.currentTarget.dataset.name;
        e != this.data[i] && (this.setData(a({}, i, e)), this.getListData());
    },
    onHide: function() {},
    onUnload: function() {},
    searchConfirm: function(a) {
        var t = a.detail;
        if (this.data.searchText != t) {
            this.setData({
                searchText: t
            });
            var e = this.data, i = e.tabsIndex, s = e.ordinaryIndex;
            0 != i || 4 != s ? this.getListData() : this.selectComponent(".livestreaming").swichTabTItem();
        }
    },
    initPage: function() {
        this.setData({
            listData: [],
            networkLoading: !1
        }), this.data.page = 1, this.data.total_page = 0, this.data.isLoadMore = !0;
    },
    getListData: function() {
        var a = this, e = this.data, i = e.tabsIndex, s = e.ordinaryIndex, n = e.ordinaryArray, r = e.searchText;
        if (0 != i || 4 != s) {
            this.initPage();
            var d = {};
            0 == i ? (d.advertisingt_type = 1, d.genre = n[s].value) : 1 == i && (d.advertisingt_type = 2), 
            d.title = r;
            var o = t.getNetAddresss("plugin.new-media-advertising.frontend.media-advertisingt.get-list");
            t._getNetWork({
                url: o,
                data: d,
                success: function(e) {
                    var i = e.data;
                    if (1 != i.result) return t.tips(i.msg);
                    a.setData({
                        isLoadMore: !0,
                        total_page: i.data.list.last_page,
                        listData: i.data.list.data,
                        is_release: i.data.is_release,
                        networkLoading: !0
                    }), a.data.total_page || (a.data.total_page = 0);
                }
            });
        }
    },
    getMoreData: function() {
        var a = this, e = t.getNetAddresss("plugin.new-media-advertising.frontend.media-advertisingt.get-list");
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page++;
            var i = this.data, s = i.tabsIndex, n = i.ordinaryIndex, r = i.ordinaryArray, d = i.searchText, o = {
                page: this.data.page
            };
            0 == s ? (o.advertisingt_type = 1, o.genre = r[n].value) : 1 == s && (o.advertisingt_type = 2), 
            o.title = d, t._getNetWork({
                url: e,
                data: o,
                success: function(t) {
                    var e = t.data;
                    if (1 == e.result) {
                        a.data.isLoadMore = !0;
                        var i = e.data.list.data;
                        a.setData({
                            listData: a.data.listData.concat(i)
                        });
                    } else a.data.isLoadMore = !1, a.data.page--;
                }
            });
        }
    },
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        0 != this.data.tabsIndex || 4 != this.data.ordinaryIndex ? this.data.isLoadMore ? this.getMoreData() : console.log("没有更多数据") : this.selectComponent(".livestreaming")._getMoreData();
    },
    onShareAppMessage: function() {}
});